package com.zztl.infiniteBand.presenter

import android.content.Context

import com.zztl.infiniteBand.base.BasePresenter
import com.zztl.infiniteBand.model.InviteIncomeBean
import com.zztl.infiniteBand.net.FilterSubscriber
import com.zztl.infiniteBand.net.RetorfitServiceManger
import com.zztl.infiniteBand.net.converter.DataConverter
import com.zztl.infiniteBand.net.requestBean.InviteIncomeRequest
import com.zztl.infiniteBand.ui.view.mvpview.RankingListView


/**
 * @desc
 * @auth ${user}
 * @time 2018/6/11  18:27
 */
class InviteIncomePresenter : BasePresenter<RankingListView>() {


    fun getInviteIncome(incomeRequest: InviteIncomeRequest, context: Context) {
        addSubscribe(RetorfitServiceManger
                .observe(RetorfitServiceManger.instance!!.apiService
                .getInviteIncome(DataConverter.instance.toJson(incomeRequest)))
                .subscribe(object : FilterSubscriber<InviteIncomeBean>(context) {

                    override fun success(bean: InviteIncomeBean) {
                        view!!.getListSuccess(bean)
                        view!!.stopRefershOrLoad()
                    }

                    override fun fail() {
                        view!!.stopRefershOrLoad()
                        super.fail()
                    }
                }))
    }
}
